package com.jd.service.impl;

import com.jd.entity.Role;
import com.jd.mapper.RoleMapper;
import com.jd.service.RoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 角色 服务实现类
 * </p>
 *
 * @author wangshuping
 * @since 2021-11-21
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {

    @Override
    public boolean isSuperAdmin(Long userId) {
        /**
         * 当用户有角色为 ADMIN_ROLE 时为超级管理员
         */
        return !StringUtils.isEmpty(baseMapper.selectRoleCode(userId, "ADMIN_ROLE"));
    }
}
